window.addEventListener('DOMContentLoaded',main);

function main() {
    var greeting = document.querySelector('#greeting');
    let datetime = new Date();
    let hours = datetime.getHours();
    if (0 <= hours && hours < 11) {
        greeting.innerHTML = "早上好!";
    } else if (11 <= hours && hours < 14){
        greeting.innerHTML = "中午好!";
    } else if (14 <= hours && hours < 18){
        greeting.innerHTML = "下午好!";
    } else if (18 <= hours && hours < 24){
        greeting.innerHTML = "晚上好!";
    }
}